@extends('mobile.template.bootstrap')
@section('title', '搜索')
@section('scripts')
<link rel="stylesheet" href="{{ asset('css/mobile-search.css') }}" />
@endsection
@section('top')
<div class="navbar  navbar-self">
	<div class="left">
		<a href="javascript:history.back();">
			<span class="fa fa-angle-left fa-fw fa-lg"></span>
		</a>
	</div>
	<div class="mid ">
		搜索
	</div>
	<div class="right">
		<a href="{{ url('/mobile') }}">
			<span class="fa fa-home fa-fw fa-lg"></span>
		</a>
	</div>
</div>
@endsection
@section('content')
<section class="search-bar">
	{!! Form::open(array('method' => 'GET', 'url' => 'mobile/search', 'class' => 'form-group')) !!}
	<div class="input-group">
		<input type="text" class="form-control" name="keywords" placeholder="作者名/书名" value="{{ $keywords }}" />
		<div class="input-group-addon" onclick="$(this).parent().parent('form').submit();">
			<span class="fa fa-search fa-fw"></span>
		</div>
	</div>
	{!! Form::close() !!}
</section>
@if(empty($keywords))
<section class="hot">
	<div class="title-container">
		<div>24小时热搜</div>
	</div>
	<div class="h-books">
		@foreach($likeBooks as $likeBook)
		<div class="h-book">
			<a href="{{ url('/mobile/books/'.$likeBook->id) }}" class="text-muted">
				<img class="book-thumbnail" src="{{ $likeBook->thumbnailUrl() }}" width="67.5" height="90" />
				{{ $likeBook->name }}
			</a>
		</div>
		@endforeach
	</div>
</section>
@else
<section class="result">
	<div class="likeBook">
		共找到<span class="text-red">{{ $books->count() }}</span>本书
	</div>
	<div class="books">
		@foreach($books as $book)
		<div class="book">
			<div class="media">
				<div class="media-left">
					<a href="{{ url('/mobile/books/'.$book->id) }}">
						<img class="book-thumbnail" class="media-object" src="{{ $book->thumbnailUrl() }}" width="67.5" height="90"/>
					</a>
				</div>
				<div class="media-body">
					<div class="media-heading">
						<div class="title">
							<a href="{{ url('/mobile/books/'.$book->id) }}">
								<h4 class="">{{ $book->name }}</h4>
								<div class="text-muted">作者：{{ $book->author }}</div>
							</a>
						</div>
						<div class="link">
							@if(Session::has($book->id))
							<a class="btn btn-sm btn-default" href="{{ url('/mobile/books/'.$book->id.'/sections/'.Session::get($book->id)) }}">
							@elseif($book->getFirstSection())
							<a class="btn btn-sm btn-default" href="{{ url('/mobile/books/'.$book->id.'/sections/'.$book->getFirstSection()->order) }}">
							@else
							<a class="btn btn-sm btn-default" href="{{ url('/mobile/books/'.$book->id) }}">
							@endif
								立即阅读
							</a>
						</div>
					</div>
					<div class="content">
						<a href="{{ url('/mobile/books/'.$book->id) }}" class="text-muted">
							{!! str_limit($book->abstract, 200) !!}
						</a>
					</div>
				</div>
			</div>
		</div>
		@endforeach
	</div>
</section>
@endif
@endsection